package com.tanguy.user.utlis.extend

import android.support.v4.app.Fragment
import android.view.Gravity
import com.findme.fecedetection.base.BasePopupWindow

/**
 * Created by dab on 2017/10/23 0023 11:30
 */
fun Fragment.showPopupWindow(window: BasePopupWindow, gravity: Int = Gravity.CENTER, x: Int = 0, y: Int = 0) {
    val activity = this.activity
    if (activity.isFinishing) {
        loge(" Activity isFinishing", 2, "err")
        return
    }
    if (window.isShowing) {
        loge(" window isShowing", 2, "err")
        return
    }
    val decorView = activity.window.decorView
    if (decorView == null) {
        loge(" decorView is null", 2, "err")
        return
    }
    window.showAtLocation(decorView, gravity, x, y)
}